import time
from Common.Base import open_browser
from Page.LoginPage import LoginPage

"""
author:李孟洋
"""
add_address_url = "http://localhost:8080/ecshop/user.php?act=address_list"
class AddressPage(LoginPage):
    country_loc = ('id','selCountries_0')
    province_loc = ('id','selProvinces_0')
    city_loc = ('id','selCities_0')
    area_loc = ('id','selDistricts_0')
    name_loc = ('id','consignee_0')
    address_loc = ('id','address_0')
    postal_code_loc = ('id','zipcode_0')
    phone_loc = ('id','tel_0')
    mobile_phone_loc = ('id','mobile_0')
    email_loc = ('id','email_0')
    add_address_loc = ('name','submit')
    delete_address_loc = ('class name','bnt_blue')
    def consignee_name(self,name):
        '''
        输入收货人名字
        :param name: 姓名
        :return:
        '''
        self.send_keys(self.name_loc,name)

    def email(self,email=None):
        '''
        输入邮箱
        :param email: 邮箱
        :return:
        '''
        e = self.find_element(self.email_loc)
        e.clear()
        self.send_keys(self.email_loc,email)

    def address(self,addr):
        '''
        输入收货地址
        :param addr: 地址
        :return:
        '''
        self.send_keys(self.address_loc,addr)


    def postal_code(self,postal):
        '''
        输入邮政编码
        :param postal:邮政编码
        :return:
        '''
        self.send_keys(self.postal_code_loc,postal)


    def phone(self,phone):
        '''
        输入电话
        :param phone: 电话
        :return:
        '''
        self.send_keys(self.phone_loc,phone)

    def mobile_phone(self,mobile):
        '''
        输入手机号
        :param mobile: 手机号
        :return:
        '''
        self.send_keys(self.mobile_phone_loc,mobile)

    def click_addr(self):
        '''
        点击新增收货地址
        :return:
        '''
        self.click(self.add_address_loc)

    def click_delete_addr(self):
        """
        点击删除键
        :return:
        """
        self.click(self.delete_address_loc)





